"""
The special characters are:
    "."      Matches any character except a newline. 除了换行符以外的所有字符
    "^"      Matches the start of the string.
    "$"      Matches the end of the string or just before the newline at
             the end of the string.
    "*"      Matches 0 or more (greedy) repetitions of the preceding RE.
             Greedy means that it will match as many repetitions as possible.
    "+"      Matches 1 or more (greedy) repetitions of the preceding RE.
    "?"      Matches 0 or 1 (greedy) of the preceding RE.
    *?,+?,?? Non-greedy versions of the previous three special characters.
    {m,n}    Matches from m to n repetitions of the preceding RE.
    {m,n}?   Non-greedy version of the above.
    "\\"     Either escapes special characters or signals a special sequence.
    []       Indicates a set of characters.
             A "^" as the first character indicates a complementing set.
    "|"      A|B, creates an RE that will match either A or B.
    (...)    Matches the RE inside the parentheses.
             The contents can be retrieved or matched later in the string.
    (?aiLmsux) Set the A, I, L, M, S, U, or X flag for the RE (see below).
    (?:...)  Non-grouping version of regular parentheses.
    (?P<name>...) The substring matched by the group is accessible by name.
    (?P=name)     Matches the text matched earlier by the group named name.
    (?#...)  A comment; ignored.
    (?=...)  Matches if ... matches next, but doesn't consume the string.
    (?!...)  Matches if ... doesn't match next.
    (?<=...) Matches if preceded by ... (must be fixed length).
    (?<!...) Matches if not preceded by ... (must be fixed length).
    (?(id/name)yes|no) Matches yes pattern if the group with id/name matched,
                       the (optional) no pattern otherwise.



The special sequences consist of "\\" and a character from the list
below.  If the ordinary character is not on the list, then the
resulting RE will match the second character.
    \number  Matches the contents of the group of the same number.
    \A       Matches only at the start of the string. 从字符串开始处匹配
    \Z       Matches only at the end of the string. 结尾处开始匹配
    \b       Matches the empty string, but only at the start or end of a word.  匹配一个 单词的边界 pyaksjd
    \B       Matches the empty string, but not at the start or end of a word.   匹配非单词的边界  aaapyzzz
    \d       Matches any decimal digit; equivalent to the set [0-9] in  任意数字
             bytes patterns or string patterns with the ASCII flag.
             In string patterns without the ASCII flag, it will match the whole
             range of Unicode digits.
    \D       Matches any non-digit character; equivalent to [^\d].  匹配任意非数字字符
    \s       Matches any whitespace character; equivalent to [ \t\n\r\f\v] in   匹配任意空白字符
             bytes patterns or string patterns with the ASCII flag.
             In string patterns without the ASCII flag, it will match the whole
             range of Unicode whitespace characters.
    \S       Matches any non-whitespace character; equivalent to [^\s]. 匹配非空白字符
    \w       Matches any alphanumeric character; equivalent to [a-zA-Z0-9_] 匹配任意字母数字 下划线
             in bytes patterns or string patterns with the ASCII flag.
             In string patterns without the ASCII flag, it will match the
             range of Unicode alphanumeric characters (letters plus digits
             plus underscore).
             With LOCALE, it will match the set [0-9_] plus characters defined
             as letters for the current locale.
    \W       Matches the complement of \w.
    \\       Matches a literal backslash.       匹配原义的反斜杠
"""

import re

s = '哈哈0'

rr = re.search('[0-9]', s)
# <re.Match object; span=(2, 3), match='0'>

print(rr)

print(rr.group())

msg = 'a7aoope88as98as89dasd9'

result = re.findall('[a-z][0-9]+[a-z]', msg)
print(result)

qq = '134523'
result = re.match('^[1-9][0-9]{4,}', qq)
print(result)

"""
正则验证次数：
    
    * 0次或者多次
    + >=1
    ? 0或者1次
    {m} m次
    {m,} >=m次
    *？，+？，？？ 即上面特殊字符的非贪婪模式
    {m,n} >=m   <=n
    {m,n}?
    
    

"""

usernme = 'admin001'

result = re.match('[a-zA-Z][0-9a-zA-Z]{5,}', usernme)
print(result)

mmm = 'aa.pu  ab.txt  bb.py kk.png  uu.py'
result = re.findall('py\\b', mmm)
print(result)

print("*" * 70)
result = re.findall(r'\w*.py\b', mmm)
print(result)

# 手机号码 正则 ：

phone = '18611112222'
result = re.match('1[345789]\d{9}]', phone)
print(result)

# 正则：：：
"""
行定位符： ^(行的开始)    $(行的结尾)
.       匹配除换行符以外的所有字符
\w      匹配 字母数字下划线或汉字
\W      匹配 除了👆上面的

\s      匹配 单个的空白符（包括 Tab 和换行符）
\S      除了👆的  

\b      匹配 单词的开始或结束，单词分界符 通常 是空格 标点或者 换行
\d      匹配 数字

?       0次或1次
+       1次或多次
*       0次或多次
{n}     n次
{n,}    最少n次
{n,m}   最少n次，最多m次

^       排除：  [^a-zA-Z]




"""

"""
^\b{8}$     匹配8位数字
[aeiou]     
[0-9]           


"""
